home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_03_02 / 3n02052a < prev    next >
Text File  |  1991-09-16  |  1KB  |  46 lines

  1. // execpgm.c example 3a
  2. // cl /AL /Lp execpgm.c
  3. // bind286 execpgm
  4. // execpgm
  5.  
  6. // execpgm.c - Example program to show how DosExecPgm is used to create
  7. // a new process. This program starts CHILD.EXE as a new process.
  8. // By having this program print "P" and "CHILD.EXE" print "C", it is 
  9. // possible to see how the execution of both processes is switched.
  10.  
  11. extern unsigned far pascal DosExecPgm
  12. (
  13.  char far *,               //BYTES output    ->FailObjName
  14.  unsigned,                 //WORD input      FailObjNameLen
  15.  unsigned,                 //WORD input      ExecType
  16.  char far *,               //ASCIIZS input   ->Arg
  17.  char far *,               //ASCZIIS input   ->Env     
  18.  struct RetInfo far *,     //DWORD   output  ->RetInfo
  19.  char far *                //ASCIIZ input    ->PgmName
  20. );
  21.  
  22. struct RetInfo
  23. {
  24.  unsigned TermCode;
  25.  unsigned RetCode ;
  26. };
  27.  
  28. #define ExecType 1
  29. #define PGM "child.exe"
  30. #define NMSG 1800
  31.  
  32. unsigned far pascal DosSleep(unsigned long);
  33.  
  34. main()
  35. {
  36.   struct RetInfo ChildInfo;
  37.   int i;
  38.   printf("parent Started ");
  39.   DosExecPgm(0l,0,ExecType,0l,0l,&ChildInfo,PGM);
  40.   for (i = 1; i <=NMSG; i++){
  41.     printf("P");
  42.     DosSleep(0);
  43.   }
  44.   printf(" parent ended ");
  45. }
  46.